package com.jinzhi.jzweb.service.impl;

import com.alibaba.druid.sql.visitor.functions.If;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.jinzhi.common.base.CoreServiceImpl;
import com.jinzhi.common.utils.Result;
import com.jinzhi.common.utils.StringUtil;
import com.jinzhi.jzweb.dao.TrackDrawDao;
import com.jinzhi.jzweb.domain.StuSignUpComDO;
import com.jinzhi.jzweb.domain.TrackDrawDO;
import com.jinzhi.jzweb.service.StuSignUpComService;
import com.jinzhi.jzweb.service.TrackDrawNanNingService;
import com.jinzhi.jzweb.service.TrackDrawService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;
import java.util.stream.Collectors;

/**
 *
 * <pre>
 * 南宁婴幼儿保育赛道抽签表（存储抽签信息）
 * </pre>
 * <small> 2023-10-16 16:36:18 | lance</small>
 */
@Service
public class TrackDrawNanNingServiceImpl extends CoreServiceImpl<TrackDrawDao, TrackDrawDO> implements TrackDrawNanNingService {

    @Autowired
    private StuSignUpComService stuSignUpComService;

    /**
     * 赛道抽签
     *
     * @param trackDrawDTO
     *          抽签逻辑：   抽赛道和场次，一个院校两名选手，不能在同一个赛道和场次  分别在1赛道和2赛道、1场次2场次和3场次4场次
     *                     抽签分两次抽 第一次抽1赛道，第二次抽2赛道
     *                     抽签分页（做一个假分页 一次抽好 分别给前端展示）
     *                     先抽1赛道、再抽2赛道（实际上也是后台一次抽好 前端分两次展示）
     *
     * @return
     *
     */
    @Override
    public Result<TrackDrawDO> selectDraw(TrackDrawDO trackDrawDTO) {
        TrackDrawDO trackDrawDO1 = new TrackDrawDO();
        //查询所有参赛选手信息
        Wrapper<StuSignUpComDO> entityWrapper =new EntityWrapper<>();
        List<StuSignUpComDO> stuSignUpComDOS = stuSignUpComService.selectList(entityWrapper);
        if(null == stuSignUpComDOS && stuSignUpComDOS.size()>0){
            return Result.fail("没有参赛选手信息，无法抽签！");
        }
        //场次号
        final List<String> placeList = new ArrayList<>(Arrays.asList("1", "2"));

        //查询出B赛场的抽签结果
        //List<TrackDrawDO> trackDrawDOS = this.selectList(new EntityWrapper<TrackDrawDO>().orderBy("sort",true));
        // 初始化序号
        //检录号
        List<String> num1List = new LinkedList<>();
        List<String> num2List = new LinkedList<>();
        int num1 = 0;
        int num2 = 0;
        for (int i = 1; i <= stuSignUpComDOS.size()/2; i++) {
            num1List.add(String.valueOf(i));
            num2List.add(String.valueOf(i));
        }
        int xianZhiNum = 0;
        int jianNum = 0;
        if(stuSignUpComDOS.size()%2!=0){
            xianZhiNum = (stuSignUpComDOS.size()-1)/4;
        }else{
            xianZhiNum=stuSignUpComDOS.size()/4;
        }
        // 随机打乱院校顺序
        Random random = new Random();//随机数
        Collections.shuffle(num1List, random);
        Collections.shuffle(num2List, random);
        System.out.println("num1List==="+num1List);
        System.out.println("num2List==="+num2List);
        // 对同一院校的选手分组
        Map<String, List<StuSignUpComDO>> trackDrawByUnitMap = stuSignUpComDOS.stream()
                .collect(Collectors.groupingBy(StuSignUpComDO::getUnitName));

        List<TrackDrawDO> trackDrawDOList = new ArrayList<>();//存储抽签结果
        //遍历 做抽签逻辑
        int i = 1;
        for (Map.Entry<String, List<StuSignUpComDO>> entry : trackDrawByUnitMap.entrySet()) {
            String unitName = entry.getKey();//键
            List<StuSignUpComDO> list = entry.getValue();//值
            //只考虑一个院校两名选手的情况
            if(!list.isEmpty() && list.size()==2){
                TrackDrawDO trackDrawDO = new TrackDrawDO();//存储本次随机结果
                trackDrawDO.setUnitName(unitName);//单位名称
                trackDrawDO.setTrack("一赛道");
                trackDrawDO.setTrack2("二赛道");
                trackDrawDO.setSort(i++);
                //打乱一下选手顺序
                Collections.shuffle(list, random);
                //判断有没有需要固定在赛道的选手
                if(null!=list.get(0).getTrackDraw() && list.get(0).getTrackDraw().equals("1")){
                    trackDrawDO.setName(list.get(0).getName());
                    trackDrawDO.setName2(list.get(1).getName());
                } else if (null!=list.get(0).getTrackDraw() && list.get(0).getTrackDraw().equals("2")) {
                    trackDrawDO.setName(list.get(1).getName());
                    trackDrawDO.setName2(list.get(0).getName());
                } else if (null!=list.get(1).getTrackDraw() && list.get(1).getTrackDraw().equals("1")) {
                    trackDrawDO.setName2(list.get(0).getName());
                    trackDrawDO.setName(list.get(1).getName());
                } else if (null!=list.get(1).getTrackDraw() && list.get(1).getTrackDraw().equals("2")) {
                    trackDrawDO.setName2(list.get(1).getName());
                    trackDrawDO.setName(list.get(0).getName());
                } else {
                    if (random.nextInt(2)==0) {
                        trackDrawDO.setName(list.get(0).getName());
                        trackDrawDO.setName2(list.get(1).getName());
                    }else {
                        trackDrawDO.setName2(list.get(0).getName());
                        trackDrawDO.setName(list.get(1).getName());
                    }
                }
                //再次打乱一下选手顺序
                Collections.shuffle(list, random);
                //判断有没有需要固定在场次的选手 2和1次数要一样

                if(num1==xianZhiNum){
                    trackDrawDO.setPlaceNum2("1");
                    trackDrawDO.setPlaceNum("2");
                } else if (num2 == xianZhiNum) {
                    trackDrawDO.setPlaceNum("1");
                    trackDrawDO.setPlaceNum2("2");
                }else{
                    if (random.nextInt(2)==0) {
                        num1+=1;
                        trackDrawDO.setPlaceNum("1");
                        trackDrawDO.setPlaceNum2("2");
                    }else {
                        num2+=1;
                        trackDrawDO.setPlaceNum2("1");
                        trackDrawDO.setPlaceNum("2");
                    }
                }

                //抽取检录号 也需要保证1和2场次的检录号相等
                if(trackDrawDO.getPlaceNum().equals("1")){
                    trackDrawDO.setTrack3(num1List.get(0));
                    num1List.remove(0);
                } else if (trackDrawDO.getPlaceNum().equals("2")) {
                    trackDrawDO.setTrack3(num2List.get(0));
                    num2List.remove(0);
                }

                if(trackDrawDO.getPlaceNum2().equals("1")){
                    trackDrawDO.setPlaceNum3(num1List.get(0));
                    num1List.remove(0);
                } else if (trackDrawDO.getPlaceNum2().equals("2")) {
                    trackDrawDO.setPlaceNum3(num2List.get(0));
                    num2List.remove(0);
                }

                trackDrawDOList.add(trackDrawDO);
            }
        }
        //同时删除之前的抽签结果和批量保存抽签的结果
        EntityWrapper<TrackDrawDO> wrapper = new EntityWrapper<>();
        this.delete(wrapper);
        if(null != trackDrawDOList && trackDrawDOList.size()>0){
            this.insertBatch(trackDrawDOList);
        }
        trackDrawDO1.setTrackDrawDOList(trackDrawDOList);
        trackDrawDO1.setHasDraw(false);

        return Result.ok(trackDrawDO1);
    }


    @Override
    public Result<List<TrackDrawDO>> signComList() {
        //查询所有参赛选手信息
        Wrapper<StuSignUpComDO> entityWrapper =new EntityWrapper<>();
        List<StuSignUpComDO> stuSignUpComDOS = stuSignUpComService.selectList(entityWrapper);
        if(null == stuSignUpComDOS && stuSignUpComDOS.size()>0){
            return Result.fail("没有参赛选手信息，无法抽签！");
        }
        stuSignUpComDOList = new ArrayList<>();
        //存储最终的抽签结果
        List<TrackDrawDO> trackDrawDOList = new ArrayList<>();

        // 打乱"stuSignUpComDOS"顺序
        Collections.shuffle(stuSignUpComDOS);
        // 对同一院校的选手分组
        Map<String, List<StuSignUpComDO>> trackDrawByUnitMap = stuSignUpComDOS.stream()
                .collect(Collectors.groupingBy(StuSignUpComDO::getUnitName));
        for (Map.Entry<String, List<StuSignUpComDO>> entry : trackDrawByUnitMap.entrySet()){
            List<StuSignUpComDO> list = entry.getValue();
            //只考虑一个院校两名选手的情况
            if(list.size() == 2){
                TrackDrawDO trackDrawDO = new TrackDrawDO();//存储本次随机结果
                trackDrawDO.setUnitName(entry.getKey());
                trackDrawDO.setTrack("一赛道");
                trackDrawDO.setTrack2("二赛道");
                trackDrawDO.setName(list.get(0).getName());
                trackDrawDO.setName2(list.get(1).getName());
                trackDrawDOList.add(trackDrawDO);
            }
        }

        return Result.ok(trackDrawDOList);
    }


    @Override
    public void updateSign() {
        Long cbatchId = 1720047287812501505L;
        String name = "张三";
        String unitNameCopy = "湖南大学";
        List<StuSignUpComDO> list = new LinkedList<>();

        for (int i = 1; i <= 200; i++) {
           String unitName = "湖南大学";
           if(i%2==0){
               unitName = unitName + i;
               unitNameCopy = unitName;
           }else{
               unitName = unitNameCopy;
           }
           StuSignUpComDO stuSignUpComDO1 = new StuSignUpComDO();
           stuSignUpComDO1.setCbatchId(cbatchId);
           stuSignUpComDO1.setUnitName(unitName);
           stuSignUpComDO1.setName(name+i);
           list.add(stuSignUpComDO1);
        }

        stuSignUpComService.insertBatch(list);
    }


    /**
     * 根据状态和页码修改抽签状态
     * @param trackDrawDTO
     */
    @Override
    public void updateByFlag(TrackDrawDO trackDrawDTO) {
        if(null != trackDrawDTO.getFlagUpdate() && null != trackDrawDTO.getPageNum()){
            Wrapper<TrackDrawDO> wrapper = new EntityWrapper<>();
            wrapper.orderBy(true,"sort");
            List<TrackDrawDO> trackDrawDOS = this.selectList(wrapper);
            //每页20条，只需要当前页数据即可 区间 = [（页码-1）*20，页码*20]
            int firstPageNum = 0;
            int lastPageNum = 0;
            if(null!=trackDrawDOS && trackDrawDOS.size()>=20){
                firstPageNum = 20;
                //判断最后一页可能是残页
                if (trackDrawDOS.size()%20==0 || (trackDrawDOS.size()%20!=0 && trackDrawDOS.size()-20*trackDrawDTO.getPageNum()>0)) {
                    lastPageNum = 20;
                } else {
                    lastPageNum = trackDrawDOS.size()%20;
                }
            }else {
                firstPageNum = trackDrawDOS.size();
                lastPageNum = trackDrawDOS.size();
            }

            List<TrackDrawDO> trackDrawDOS1 = trackDrawDOS.subList((trackDrawDTO.getPageNum() - 1) * firstPageNum, (trackDrawDTO.getPageNum()-1) * firstPageNum + lastPageNum);
            for (TrackDrawDO trackDrawDO : trackDrawDOS1) {
                trackDrawDO.setFlagUpdate(trackDrawDTO.getFlagUpdate());
                trackDrawDO.setPageNum(trackDrawDTO.getPageNum());
            }
            this.updateBatchById(trackDrawDOS1);
        }
    }


    /**
     * 查询上一次的抽签结果
     * @param trackDrawDTO
     * @return
     */
    @Override
    public Result<TrackDrawDO> trackList(TrackDrawDO trackDrawDTO) {
        TrackDrawDO resultVO = new TrackDrawDO();
        resultVO.setHasDraw(true);
        //查询上一次的抽签结果
        Wrapper<TrackDrawDO> wrapper = new EntityWrapper<>();
        wrapper.orderBy(true,"sort");
        List<TrackDrawDO> trackDrawDOsList = this.selectList(wrapper);
        if(null!=trackDrawDOsList && !trackDrawDOsList.isEmpty()){
            resultVO.setTrackDrawDOList(trackDrawDOsList);
        }else {
            resultVO.setHasDraw(false);
            //查询所有参赛选手信息
            Wrapper<StuSignUpComDO> entityWrapper =new EntityWrapper<>();
            List<StuSignUpComDO> stuSignUpComDOS = stuSignUpComService.selectList(entityWrapper);
            if(null == stuSignUpComDOS && stuSignUpComDOS.size()>0){
                return Result.fail("没有参赛选手信息，无法抽签！");
            }
            stuSignUpComDOList = new ArrayList<>();

            List<TrackDrawDO> trackDrawDOList = new ArrayList<>();
            // 打乱"stuSignUpComDOS"顺序
            Collections.shuffle(stuSignUpComDOS);
            // 对同一院校的选手分组
            Map<String, List<StuSignUpComDO>> trackDrawByUnitMap = stuSignUpComDOS.stream()
                    .collect(Collectors.groupingBy(StuSignUpComDO::getUnitName));
            for (Map.Entry<String, List<StuSignUpComDO>> entry : trackDrawByUnitMap.entrySet()){
                List<StuSignUpComDO> list = entry.getValue();
                //只考虑一个院校两名选手的情况
                if(list.size() == 2){
                    TrackDrawDO trackDrawDO = new TrackDrawDO();//存储本次随机结果
                    trackDrawDO.setUnitName(entry.getKey());
                    trackDrawDO.setTrack("一赛道");
                    trackDrawDO.setTrack2("二赛道");
                    trackDrawDO.setName(list.get(0).getName());
                    trackDrawDO.setName2(list.get(1).getName());
                    trackDrawDOList.add(trackDrawDO);
                    resultVO.setTrackDrawDOList(trackDrawDOList);
                }
            }
        }

        return Result.ok(resultVO);
    }


    /**
     * 赛道抽签
     *
     * @param trackDrawDTO
     *          抽签逻辑：   新疆的婴幼儿保育赛项是团队赛，目前报名情况是45个队，90个人；分为1号赛道和2号赛道。1-45是1号赛道，46-90是2号赛道。
     *          每个队2名选手，随机分配到两个赛道，也就是一个在1-45号中不重复的随机号码，另外一个在46-90号中的不重复的随机号码。
     *
     * @return
     *
     */
//    @Override
//    public Result<List<TrackDrawDO>> selectDraw(TrackDrawDO trackDrawDTO) {
//        //查询所有参赛选手信息
//        Wrapper<StuSignUpComDO> entityWrapper =new EntityWrapper<>();
//        List<StuSignUpComDO> stuSignUpComDOS = stuSignUpComService.selectList(entityWrapper);
//        if(null == stuSignUpComDOS && stuSignUpComDOS.size()>0){
//            return Result.fail("没有参赛选手信息，无法抽签！");
//        }
//        // 初始化序号
//        List<String> sessions = new LinkedList<>();
//        for (int i = 1; i <= stuSignUpComDOS.size(); i++) {
//            sessions.add(String.valueOf(i));
//        }
//        List<String> sessionsBack = new LinkedList<>(sessions);
//        // 随机打乱院校顺序
//        Random random = new Random();
//        Collections.shuffle(sessions, random); // 随机打乱赛道
//        //存储抽签记录
//        List<TrackDrawDO> trackDrawDOList = new LinkedList<>();
//
//        int j = 0;//同于记录排序
//        Map<String,TrackDrawDO> map = new HashMap<>();//存储已经抽签过的记录
//        List<StuSignUpComDO> students = stuSignUpComDOS.stream()
//                .sorted(Comparator.comparing(student -> student.getTrackDraw(), Comparator.nullsLast(Comparator.naturalOrder())))
//                .collect(Collectors.toList());
//        //在循环院校中的选手 循环选手的时候注意 同有个院校的选手要在不同赛道（当选手多于赛道的时候，则允许同有个院校的选手同赛道）
//        for (int i = 0; i < students.size(); i++) {
//            TrackDrawDO trackDrawDO = new TrackDrawDO();
//            trackDrawDO.setUnitName(students.get(i).getUnitName());//学校名称
//            //先判断map中是否已经包含，包含则说明该学校已经有选手抽签过一次了，只需要抽第二位选手信息即可
//            if(map.containsKey(students.get(i).getUnitName())){
//                trackDrawDO = map.get(students.get(i).getUnitName());
//                trackDrawDO.setName2(students.get(i).getName());
//                //如果选手已经固定了，则不需要在随机分配啦
//                if(StringUtils.isNotBlank(students.get(i).getTrackDraw())){
//                    trackDrawDO.setPlaceNum2(students.get(i).getTrackDraw());
//                    sessions.remove(students.get(i).getTrackDraw());//选手固定的序号
//                }else {
//                    //抽签
//                    //先判断同校的选手是在1赛道还是2赛道，确保赛道不同
//                    int num = 0;
//                    if(Integer.valueOf(trackDrawDO.getPlaceNum())<=sessionsBack.size()/2){
//                        //随机数需要满足在2赛道
//                        num = 0;
//                        while (true){
//                            //大于45 并且 sessions中含有该序号
//                            if(Integer.valueOf(sessions.get(num))>sessionsBack.size()/2 && sessions.contains(sessions.get(num))){
//                                break;
//                            }
//                            num++;
//                        }
//                    }else{
//                        //随机数需要满足在1赛道
//                        num = 0;
//                        while (true){
//                            if(Integer.valueOf(sessions.get(num))<=sessionsBack.size()/2 && sessions.contains(sessions.get(num))){
//                                break;
//                            }
//                            num++;
//                        }
//                    }
//                    trackDrawDO.setPlaceNum2(String.valueOf(sessions.get(num)));
//                    sessions.remove(String.valueOf(sessions.get(num)));
//                }
//            }else{
//                //先抽一号选手的序号
//                trackDrawDO.setName(students.get(i).getName());
//                //如果选手已经固定了，则不需要在随机分配啦
//                if(StringUtils.isNotBlank(students.get(i).getTrackDraw())){
//                    trackDrawDO.setPlaceNum(students.get(i).getTrackDraw());
//                    sessions.remove(students.get(i).getTrackDraw());//选手固定的序号
//                }else {
//                    trackDrawDO.setPlaceNum(String.valueOf(sessions.get(0)));
//                    sessions.remove(String.valueOf(sessions.get(0)));
//                }
//            }
//
//            map.put(trackDrawDO.getUnitName(),trackDrawDO);
//        }
//
//        //遍历map
//        for( Map.Entry<String,TrackDrawDO> entry : map.entrySet()){
//            trackDrawDOList.add(entry.getValue());
//        }
//        //打乱”trackDrawDOList“顺序
//        Collections.shuffle(trackDrawDOList, random);
//        int i = 1;//添加序号
//        for (TrackDrawDO trackDrawDO : trackDrawDOList) {
//            trackDrawDO.setSort(i++);
//        }
//
//        //同时删除之前的抽签结果和批量保存抽签的结果
//        EntityWrapper<TrackDrawDO> wrapper = new EntityWrapper<>();
//        this.delete(wrapper);
//        if(null != trackDrawDOList && trackDrawDOList.size()>0){
//            this.insertBatch(trackDrawDOList);
//        }
//
//
//        return Result.ok(trackDrawDOList);
//    }


    /**
     * 广东赛道抽签  规则：
     *  如总共一个40个学校，80个选手，分为A、B两个组，第一次先抽A ,第二次抽B,一个学校的选手一个在A,一个在B
     * @param trackDrawDTO
     * @return
     */
    @Override
    public Result<List<TrackDrawDO>> selectDrawGuangDong(TrackDrawDO trackDrawDTO) {
        if(trackDrawDTO.getDrawType()==1){
            return this.drawGuangDongA();
        }else if(trackDrawDTO.getDrawType()==2){
            return this.drawGuangDongB();
        }else{
            return Result.fail("抽签异常！未明确需要抽签的赛道！");
        }

    }

    private List<StuSignUpComDO> stuSignUpComDOList = new ArrayList<>();



    public Result<List<TrackDrawDO>> drawGuangDongA(){
        //查询所有参赛选手信息
        Wrapper<StuSignUpComDO> entityWrapper =new EntityWrapper<>();
        List<StuSignUpComDO> stuSignUpComDOS = stuSignUpComService.selectList(entityWrapper);
        if(null == stuSignUpComDOS && stuSignUpComDOS.size()>0){
            return Result.fail("没有参赛选手信息，无法抽签！");
        }
        stuSignUpComDOList = new ArrayList<>();
        //存储最终的抽签结果
        List<TrackDrawDO> trackDrawDOList = new ArrayList<>();

        // 打乱"stuSignUpComDOS"顺序
        Collections.shuffle(stuSignUpComDOS);
        // 对同一院校的选手分组
        Map<String, List<StuSignUpComDO>> trackDrawByUnitMap = stuSignUpComDOS.stream()
                .collect(Collectors.groupingBy(StuSignUpComDO::getUnitName));

        /**
         * 打乱“trackDrawByUnitMap”的顺序，用“shuffledMap”保存打乱后的数据 等于是在打乱A\B赛场的顺序
         */
        // 将键转换为列表
        List<String> keys = new ArrayList<>(trackDrawByUnitMap.keySet());
        // 对键进行排序
        Collections.shuffle(keys); // 打乱键的顺序
        // 创建一个新的有序 LinkedHashMap，按照排序后的顺序将键和值放入其中
        Map<String, List<StuSignUpComDO>> shuffledMap = new LinkedHashMap<>();
        for (String key : keys) {
            shuffledMap.put(key, trackDrawByUnitMap.get(key));
        }
        int i = 1;
        for (Map.Entry<String, List<StuSignUpComDO>> entry : shuffledMap.entrySet()){
            //打乱两位选手的顺序
            Collections.shuffle(entry.getValue());
            //取每个的第一条当作第一天的抽签结果
            TrackDrawDO trackDrawDO = new TrackDrawDO();
            trackDrawDO.setUnitName(entry.getKey());
            trackDrawDO.setName(entry.getValue().get(0).getName());
            trackDrawDO.setPlaceNum(i + "-" + entry.getValue().get(0).getName());
            trackDrawDO.setTrack(i + "");
            trackDrawDOList.add(trackDrawDO);
            //存未抽签的数据
            stuSignUpComDOList.add(entry.getValue().get(1));
            i++;
        }

        //打乱trackDrawDOList顺序
        Collections.shuffle(trackDrawDOList);
        int j = 1;
        for (TrackDrawDO trackDrawDO : trackDrawDOList) {
            trackDrawDO.setSort(j++);
        }

        //同时删除之前的抽签结果和批量保存抽签的结果
        EntityWrapper<TrackDrawDO> wrapper = new EntityWrapper<>();
        this.delete(wrapper);
        if(!trackDrawDOList.isEmpty()){
            this.insertBatch(trackDrawDOList);
        }


        return Result.ok(trackDrawDOList);
    }

    public Result<List<TrackDrawDO>> drawGuangDongB(){
        //查询出A的抽签结果
        List<TrackDrawDO> trackDrawDOS = this.selectList(new EntityWrapper<TrackDrawDO>().orderBy("sort",true));
        //打乱未抽签的顺序 然后依次分配序号
        Collections.shuffle(stuSignUpComDOList);
        for (int i = 1; i <= stuSignUpComDOList.size(); i++) {
            //暂且用state当作排序
            stuSignUpComDOList.get(i-1).setState(i);
        }

        if(null!=trackDrawDOS &&  !trackDrawDOS.isEmpty()){
            for (TrackDrawDO trackDrawDO : trackDrawDOS) {
                //遍历
                for (StuSignUpComDO stuSignUpComDO : stuSignUpComDOList) {
                    if (stuSignUpComDO.getUnitName().equals(trackDrawDO.getUnitName())) {
                        trackDrawDO.setName2(stuSignUpComDO.getName());
                        trackDrawDO.setPlaceNum2(stuSignUpComDO.getState() + "-" + stuSignUpComDO.getName());
                        trackDrawDO.setTrack2(stuSignUpComDO.getState() + "");
                        break; //一旦找到匹配项，就跳出循环
                    }
                }
            }
            this.updateBatchById(trackDrawDOS);
            return Result.ok(trackDrawDOS);
        }


        return Result.ok(trackDrawDOS);
    }


}
